function [v]=ModifiedGS(A)
%MODIFIEDGS:A is transform into a orthogonal matrix v using modified
%Gram-Schmidt methods
%A is input Matrix;
%v is orthogonal matrix used modified Gram-Schmidt methods

[ARow,ACol]=size(A);

v(:,1)=A(:,1)/norm(A(:,1));

for k=2:ARow
    
    for i=k:ACol
        %modify residual vector
        A(:,i)=A(:,i)-A(:,i)'*v(:,k-1)*v(:,k-1);
        
    end
    %normalized orthogonal vector obtained by this time
    v(:,k)=A(:,k)/norm(A(:,k));
    
end